package com.systop.student.service.impl;

import com.systop.common.pojo.Student;
import com.systop.common.util.CommonResult;
import com.systop.student.mapper.StudentMapper;
import com.systop.student.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)  //开启事务 回滚
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public CommonResult list() {
        List<Student> list = studentMapper.list();
        return new CommonResult(200,"ok",1,list);
    }

    @Override
    public CommonResult findByname(String s_no) {
        Student byname = studentMapper.findByname(s_no);
        return new CommonResult(200,"ok",1,byname);
    }
}
